﻿using Cognitum.CassandraProviders.Cassandra;
using Cognitum.EmailSenders;
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace Cognitum.ProvidersTests
{
    [TestFixture]
    internal class SendEmailTest
    {
        [Test]
        public void SendEmail()
        {
            string ApplicationName = "ApplicationName";
            string providerKey = "providerKey";
            // Now lets create an email message
            var emailMessage = new StringBuilder();
            string header = "Your " + ApplicationName + " account has been locked out!";
            emailMessage.Append(header);
            emailMessage.Append(string.Format("Hello, {0}.<br />Someone, possibly you, have {1} bad sign in attempts to your " + ApplicationName + " account. Because of this your account was automatically locked out to prevent a possible account password hacking attempt. ", "ada", "dadadsa"));
            emailMessage.Append("You can't sign in to " + ApplicationName + " until your account is unlocked. To unlock your " + ApplicationName + " account again please click the link below:<br /><br />");
            string url = string.Format("http://www.MyApp.com/Account/UnlockAccount.aspx?Id={0}", providerKey);
            emailMessage.Append(string.Format("<a href='{0}'>{0}</a><br /><br />", url));
            emailMessage.Append("If your e-mail client does not allow links then copy & paste the above url into your browser address bar.");
            string footer = String.Format("This e-mail was sent your user account at <a href=\"http://www." + ApplicationName + ".com\">www." + ApplicationName + ".com</a> was locked out because of too many bad sign attempt.");
            emailMessage.Append(footer);
            string fromEmail = "cassandraprovider@gmail.com";
            string password = "cassandra2014";

            IEmailSender emailSender = new EmailSender();
            emailSender.SendAsyncEmail(fromEmail, "cassandraprovider@gmail.com", password, "Unlock your MyApp account", emailMessage.ToString());
            //      Thread.Sleep(20000);

            Assert.Fail("Check cassandraprovider@gmail.com mail box password: cassandra2014");
        }
    }
}